/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Models;

import EntitiesTier.ClLiquidacao;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Douglas
 */
public class LiquidacaoTableModel extends AbstractTableModel{
    
    private List<ClLiquidacao> coliq;
    private List<String> colunas;

    
    public LiquidacaoTableModel(List<ClLiquidacao> coliq) throws Exception
    {
       this.coliq = coliq;
       colunas = Arrays.asList("Cod.", "Contrato", "Data", "Nota/Documento Fiscal - Série", "Valor");
    }
        
    @Override
    public int getRowCount() {
        return coliq.size();
    }

    @Override
    public int getColumnCount() {
        return 5;
    }

    @Override
    public Object getValueAt(int lin, int col) {
        ClLiquidacao liq = coliq.get(lin);
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        switch(col)
        {
            case 0 : return liq.getLIQ_COD();
            case 1 : return liq.getLIQ_CONT();
            case 2 : return df.format(liq.getLIQ_DATA());
            case 3 : return (liq.getLIQ_NF() + " - " + liq.getLIQ_SERIE());
            case 4 : return liq.getLIQ_VALOR();
            default : return "";
        }
    }

    @Override
    public String getColumnName(int col) {
        return colunas.get(col);
    }
    
    
}
